package com.pojo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StudentService {
       StudentDao studentDao;

       @Autowired
    public void setStudentDao(StudentDao studentDao)
       {
           this.studentDao=studentDao;
           System.out.println(studentDao.toString());

       }
    @Transactional
    public void insert(Student student) {
           studentDao.addStudent(student);
    }

    @Transactional
    public Student selectById(int id)
    {
        Student student=studentDao.getStudentById(id);
        return student;
    }

    @Transactional
    public List<Student>  queryAll()
    {
        return studentDao.getAllStudent();
    }
    @Transactional
    public void  delete(Student student)
    {
        studentDao.deleteStudent(student);
    }
}
